import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    redirect: '/home',
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/Login/index.vue'),
  },
  {
    path: '/home',
    name: 'Home',
    redirect: '/welcome',
    component: () => import('../views/Home/index.vue'),
    children: [
      {
        path: '/welcome',
        name: 'welcome',
        meta: { name: '首页' },
        component: () => import('../views/welcome/index.vue'),
      },
      {
        path: '/users',
        name: 'User',
        meta: { name: '用户列表', authName: '用户管理' },
        component: () => import('../views/User/index.vue'),
      },
      {
        path: '/roles',
        name: 'roles',
        meta: { name: '权限列表', authName: '权限管理' },
        component: () => import('../views/Role/roles/index.vue'),
      },
      {
        path: '/rights',
        name: 'rights',
        meta: { name: '角色列表', authName: '权限管理' },
        component: () => import('../views/Role/right/index.vue'),
      },
      {
        path: '/reports',
        name: 'Reports',
        meta: { name: '订单列表', authName: '订单管理' },
        component: () => import('../views/reports/index.vue'),
      },
      {
        path: '/orders',
        name: 'orders',
        meta: { name: '订单管理', authName: '订单列表' },
        component: () => import('../views/orders/index.vue'),
      },
      {
        path: '/goods',
        name: 'goods',
        meta: { name: '商品列表', authName: '商品管理' },
        component: () => import('../views/goods/index.vue'),
      },
      {
        path: '/params',
        name: 'params',
        meta: { name: '分类参数', authName: '商品管理' },
        component: () => import('../views/params/index.vue'),
      },
      {
        path: '/categories',
        name: 'categories',
        meta: { name: '商品分类', authName: '商品管理' },
        component: () => import('../views/categories/index.vue'),
      },
      {
        path: '/goods/add',
        name: 'goodsAdd',
        meta: { name: '添加商品', authName: '商品管理' },
        component: () => import('../views/goods/addGoods.vue'),
      },
    ],
  },
];

const router = new VueRouter({
  routes,
});

export default router;
